﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using rock.UI.common;
using rock.dataset.RentalHousingManagerDataSetTableAdapters;
 
 

namespace rock.UI.report
{
    public partial class UserControlZhujingAllReport : UserControl
    {
        int XiaoQuSeqid = -1;
        int DongSeqid = -1;
        int ContranctStatus = -1;
        String yyyymm = "";
        public UserControlZhujingAllReport()
        {
           InitializeComponent();
           this.userControlLeftTree1.selectedTreeinfo = selectedTreeinfo;
         
          
        }

       private void UserControlYajingReport_Load(object sender, EventArgs e)
       {
           this.Dock = DockStyle.Fill;
           this.reportViewer1.LocalReport.ReportEmbeddedResource = "rock.UI.report.ZhujingAllReport.rdlc";


           //年下拉框
           List<ComboBoxInfo> years = new List<ComboBoxInfo>();
           years.Add(new ComboBoxInfo { IntId = 0, Name = "全部" });
           for (int i = 2012; i <= 2042; i++)
           {
               years.Add(new ComboBoxInfo { IntId = i, Name = i + "" });
           }
           

           this.comboBox1Year.DisplayMember = "Name";
           this.comboBox1Year.ValueMember = "IntId";
           this.comboBox1Year.DataSource = years;
           this.comboBox1Year.SelectedValue = DateTime.Now.Year;

           //月下拉框
           List<ComboBoxInfo> months = new List<ComboBoxInfo>();
           months.Add(new ComboBoxInfo { Id = "00", Name = "全年" });
           for (int i = 1; i <= 12; i++)
           {
               string value = i < 10 ? ("0" + i) : (i + "");
                
               months.Add(new ComboBoxInfo { Id = value, Name = value });
           }
           
           this.comboBox2Month.DisplayMember = "Name";
           this.comboBox2Month.ValueMember = "Id";
           this.comboBox2Month.DataSource = months;
           this.comboBox2Month.SelectedIndex = 0; 
           refreshDate();
       }

       private void selectedTreeinfo(TreeInfo treeinfo)
       {
           if (treeinfo.NodeType == 0)
           {
               this.XiaoQuSeqid = -1;
               this.DongSeqid = -1;
           }
           else if (treeinfo.NodeType == 1)
           {
               this.XiaoQuSeqid = treeinfo.Id;
               this.DongSeqid = -1;
           }
           else if (treeinfo.NodeType == 2)
           {
               this.XiaoQuSeqid = -1;
               this.DongSeqid = treeinfo.Id;
           }

         this.refreshDate();
       }
       rock.dataset.RentalHousingManagerDataSetTableAdapters.REPORT_ZhujingTableAdapter REPORT_ZhujingTableAdapter;
       public void refreshDate() {



           this.REPORT_ZhujingTableAdapter = new rock.dataset.RentalHousingManagerDataSetTableAdapters.REPORT_ZhujingTableAdapter();
          // this.vIEW_REPORT_YAJINGTableAdapter.Fill(this.rentalHousingManagerDataSet.VIEW_REPORT_YAJING);


           this.REPORT_ZhujingTableAdapter.FillByREPORT_Zhujing(this.rentalHousingManagerDataSet.REPORT_Zhujing, this.XiaoQuSeqid, this.DongSeqid, this.ContranctStatus, yyyymm);
               //.FillBy(this.rentalHousingManagerDataSet.VIEW_REPORT_YAJING, this.XiaoQuSeqid, this.DongSeqid, this.ContranctStatus);
           this.reportViewer1.RefreshReport();
       }

       private void button1_Click(object sender, EventArgs e)
       {
           int year = (int)this.comboBox1Year.SelectedValue;
           String month = (String)this.comboBox2Month.SelectedValue;
           this.yyyymm = "";
           if(year != 0){
               yyyymm += year + "";
               if (!month.Equals("00"))
               {
                   yyyymm += month + "";
               }
           }
          
           refreshDate();
       }

        

       
    }
}
